package com.fr.web.core.service;

import com.fr.base.ColumnRow;
import com.fr.base.core.html.Tag;
import com.fr.base.core.util.TemplateUtils;
import com.fr.report.Report;
import com.fr.report.ReportSettings;
import com.fr.report.SheetPage;
import com.fr.web.Browser;
import com.fr.web.Repository;
import com.fr.web.core.HTMLConverter;
import com.fr.web.core.SessionIDInfor;
import com.fr.web.core.WebUtils;
import com.fr.web.core.chwriter.FormCellWriter;
import java.io.PrintWriter;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SimpleSheetService
{
  public static void dealWithSimpleSheet(SessionIDInfor paramSessionIDInfor, HttpServletRequest paramHttpServletRequest, HttpServletResponse paramHttpServletResponse, Map paramMap)
    throws Exception
  {
    int i = 0;
    Report localReport = paramSessionIDInfor.getReport2Show(i);
    SheetPage localSheetPage = new SheetPage(localReport);
    ColumnRow localColumnRow = null;
    if ((localReport.getReportSettings() != null) && (localReport.getReportSettings().getWriteFrozenColumnRow() != null))
      localColumnRow = localReport.getReportSettings().getWriteFrozenColumnRow();
    Tag localTag1 = new Tag("div").cls("formContentDIV");
    Repository localRepository = new Repository(paramHttpServletRequest, paramSessionIDInfor);
    new HTMLConverter(localSheetPage, new FormCellWriter(localRepository, i), localColumnRow, localRepository, localTag1, true).convert();
    if (localRepository.getBrowser().shouldWrapCenter())
    {
      localTag2 = localTag1;
      localTag1 = new Tag("center").sub(localTag2);
    }
    Tag localTag2 = new Tag("form").attr("name", "form-" + paramSessionIDInfor.getReportName(i)).cls("form-submit");
    localTag1.sub(localTag2);
    PrintWriter localPrintWriter = WebUtils.createPrintWriter(paramHttpServletResponse);
    TemplateUtils.dealWithTemplate("/com/fr/web/core/simple_sheet.html", localPrintWriter, paramMap);
    localTag1.writeHtml(localPrintWriter);
    localPrintWriter.println("</body>");
    localPrintWriter.println("</html>");
    localPrintWriter.flush();
    localPrintWriter.close();
  }
}